
var base_url = 'http://localhost:8079';
var led_topic = 'controlLed';
var led_api = 'mqtt/led'
export default{
  controlLed(isOn,deviceId){
    //发起请求
    console.log(deviceId);
    wx.request({
      url: `${base_url}/${led_api}/${led_topic}`,
      method: 'POST',
      header:{
        'content-type': 'application/json' // 默认值
      },
      data:{
        isOn:isOn,
        online:true,
        deviceId:deviceId,
      }
    })
  },
  controlStreamOnOff(isStreamOn,speed,deviceId){
    wx.request({
      url: `${base_url}/${led_api}/LedStream/${led_topic}`,
      method: 'POST',
      header:{
        'content-type': 'application/json' // 默认值
      },
      data:{
        isStreamLedOn:isStreamOn,
        speed:speed,
        online:true,
        deviceId:deviceId
      },
    })
  },
  controlStreamLedSpeed(speed,deviceId){
    wx.request({
      url: `${base_url}/${led_api}/LedStreamSpeed/${led_topic}`,
      method: 'POST',
      header:{
        'content-type': 'application/json' // 默认值
      },
      data:{
        speed:speed,
        isStreamLedOn:true,
        online:true,
        deviceId:deviceId,
      }
    })
  }
}